<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Editor</title>
    <style type="text/css" media="screen">

    </style>
    <link rel="stylesheet" href="<?php echo (ADMIN_BOOT_URL); ?>css/bootstrap.min.css">
</head>
<body>

<pre id="editor"></pre>

<div style="text-align: center">
<button type="button" class="btn btn-info" onclick="ss()">确认</button>
<button type="button" class="btn btn-warning">取消</button>
</div>

<script src="<?php echo (ACE_URL); ?>demo/kitchen-sink/require.js"></script>
<script src="<?php echo (SITE_PATH); ?>Public/jquery/jquery.min.js"></script>
<script src="<?php echo (ADMIN_BOOT_URL); ?>js/bootstrap.min.js"></script>
<script>
    // setup paths
    require.config({paths: { "ace" : "<?php echo (ACE_URL); ?>/lib/ace"}});
    // load ace and extensions
    require(["ace/ace"], function(ace) {
        var editor = ace.edit("editor");
        editor.setTheme("ace/theme/monokai");//设置风格
        editor.session.setMode("ace/mode/php");//设置语言类型
        editor.setAutoScrollEditorIntoView(true);//滚动
        editor.setOption("minLines", 25);
        editor.setOption("maxLines", 45);
    });
    function ss(){
        var el = document.getElementById('editor');
        var content = el.env.editor.getValue();
//        console.log(content);
        var host = location.origin;
        var dataParrass = {"php":content};
        $.ajax({
            type:"post",
            url:host+"/cloud/index.php/Admin/Ace/ajax_save",
            data:dataParrass,
            dataType:"json",
            error: function (request) {
                alert("错误:"+request);
            },
            success:function(result){
              if(result == 1){
                  alert("修改成功");
              }else if(result == 0){
                  alert("您没有修改数据");
              }else{
                  alert("修改失败");
              }
            }
        });
    }

</script>

<script src="<?php echo (ACE_URL); ?>demo/show_own_source.js"></script>

</body>
</html>